//============================================================================
// Copyright (C) 2008-2013 Brett R. Jones 
//
// Issued to public domain 2013
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#include "VxNetLib.h"
#include "VxSktAccept.h"
#include <VxUtilLib/VxParse.h>

//============================================================================
//=== constructor ===//
VxSktAccept::VxSktAccept()
{
	m_eSktType = eSktTypeTcpAccept;
}
//============================================================================
//=== destructor ===//
VxSktAccept::~VxSktAccept()
{
}

//============================================================================
//! called when socket is accepted
RCODE	VxSktAccept::DoAccept( VxSktAcceptMgr * poMgr, struct sockaddr_storage& oAcceptAddr )
{
	m_poSktMgr = poMgr;
	m_eSktCallbackReason = eSktCallbackReasonConnecting;
	// get the peer address
	SetRmtAddress( oAcceptAddr );

	// tell user we connecting
	//VxVerifyCodePtr( m_pfnRecieve );
	m_pfnRecieve( this );
	// make a useful thread name
	std::string strThreadName;
	StdStringFormat( strThreadName, "VxSktBaseAccept%d", m_iSktId );
#ifdef DEBUG_SKT
	log_msg( 0, "VxSktAccept::DoAccept skt %d\n", this->m_iSktId );
#endif // DEBUG_SKT
	return StartRecieveThread( strThreadName.c_str() );
}

